package com.czk.ssastreamingoutput.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @Author: chenzhangkun
 * @CreateTime: 2025-10-14
 * @Description:
 * @Version: 1.0
 */
@RestController
public class ChatClientMultiModelController {

    @Resource(name = "deepseekChatClient")
    private ChatClient deepeekChatClient;
    @Resource(name = "qwenChatClient")
    private ChatClient qwenChatClient;

    /**
     * @return java.lang.String
     * @Author chenzhangkun
     * @Description 通用调用，阻塞性返回
     * @Date 20:43 2025/10/12
     * @Param [msg]
     **/
    @GetMapping(value = "/hello/dochat/stream/chatclient-ds")
    public Flux<String> doChat(@RequestParam(name = "msg", defaultValue = "你是谁") String msg) {
        return deepeekChatClient.prompt().user(msg).stream().content();
    }

    /**
     * 流式返回
     *
     * @param msg
     * @return
     */
    @GetMapping(value = "/hello/dochat/stream/chatclient-qw")
    public Flux<String> doChatStream(@RequestParam(name = "msg", defaultValue = "你是谁") String msg) {
        return qwenChatClient.prompt().user(msg).stream().content();
    }

}
